package com.hmyuan.service.impl;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hmyuan.dao.Sys_res_roleMapper;
import com.hmyuan.dao.TagMapper;
import com.hmyuan.domain.Tag;
import com.hmyuan.service.TagService;
@Service("tagService")
public class TagServiceImpl implements TagService {
	@Resource
	TagMapper tagMapper;
	
	@Override
	public PageInfo<Tag> selectListByPage(Tag tag,
			int pageNum, int pageSize) {
		// TODO Auto-generated method stub
		PageHelper.startPage(pageNum, pageSize); // 核心分页代码
		List<Tag> list = tagMapper.selectList(tag);
		PageInfo<Tag> pageInfo = new PageInfo<Tag>(list);
		
		return pageInfo;
	}

	@Override
	public boolean insert(Tag tag) {
		// TODO Auto-generated method stub
		tag.setCreatetime(new Date());
		tag.setStatus(0);
		tag.setUsenum(0l);
		int num = tagMapper.insert(tag);
		return num==1?true:false;
	}

	@Override
	public Tag selectByPrimaryKey(Long id) {
		// TODO Auto-generated method stub
		return tagMapper.selectByPrimaryKey(id);
	}

	@Override
	public boolean updateByPrimaryKeySelective(Tag tag) {
		// TODO Auto-generated method stub
		int num = tagMapper.updateByPrimaryKeySelective(tag);
		return num==1?true:false;
	}

	@Override
	public boolean deletetagById(Long id) {
		// TODO Auto-generated method stub
		int num = tagMapper.deleteByPrimaryKey(id);
		return num==1?true:false;
	}

	@Override
	public List<Tag> selectList(Tag tag) {
		// TODO Auto-generated method stub
		return tagMapper.selectList(tag);
	}

	@Override
	public List<Tag> selectListByArticleid(Long articleid) {
		// TODO Auto-generated method stub
		return tagMapper.selectListByArticleid(articleid);
	}

	@Override
	public List<Tag> selectListWithCount() {
		// TODO Auto-generated method stub
		return tagMapper.selectListWithCount();
	}
}
